nodejs pm2配置使用教程-linux-操作系统-壹聚教程网

创建时间:2016/8/2 10:16
来源:http://www.111cn.net/sys/linux/100927.htm


nodejs pm2配置使用教程

www.111cn.net 编辑:jimmy 来源:转载
pm2是非常优秀工具,它提供对基于node.js的项目运行托管服务。它基于命令行界面,提供很多特性: 内置的负载均衡器等等,下面我们就一起来看看吧。

一、简介

pm2是一个带有负载均衡功能的应用进程管理器,类似有Supervisor,forever。

二、安装

Linux Binaries下载地址:https://nodejs.org/dist
cd oneinstack/src
wget https://nodejs.org/dist/v4.2.4/node-v4.2.4-linux-x64.tar.gz
tar xzf node-v4.2.4-linux-x64.tar.gz
cp node-v4.2.4-linux-x64/bin/node /usr/local/bin/
cp -R node-v4.2.4-linux-x64/lib/node_modules /usr/local/lib/
ln -s /usr/local/lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm
npm install pm2@latest -g #安装最新版本pm2模块
PS: 如果你的主机无法连接公网,先找到能连公网的主机安装上面的方法安装pm2,然后拷贝到你要安装的主机。拷贝如下目录:
/usr/local/bin/node
/usr/local/lib/node_modules
再创建相关软连接

三、PM2常用命令

假设你现在已经写好了一个app.js的文件,需要启动,你可以使用pm2进行管理

1. 启动

# pm2 start app.js
# pm2 start app.js --name my-api   #my-api为PM2进程名称
# pm2 start app.js -i 0           #根据CPU核数启动进程个数
# pm2 start app.js --watch   #实时监控app.js的方式启动,当app.js文件有变动时,pm2会自动reload
2. 查看进程
# pm2 list
# pm2 show 0 或者 # pm2 info 0  #查看进程详细信息,0为PM2进程id
3. 监控
# pm2 monit
4. 停止
# pm2 stop all  #停止PM2列表中所有的进程
# pm2 stop 0    #停止PM2列表中进程为0的进程
5. 重载
# pm2 reload all    #重载PM2列表中所有的进程
# pm2 reload 0     #重载PM2列表中进程为0的进程
6. 重启
# pm2 restart all     #重启PM2列表中所有的进程
# pm2 restart 0      #重启PM2列表中进程为0的进程
7. 删除PM2进程
# pm2 delete 0     #删除PM2列表中进程为0的进程
# pm2 delete all   #删除PM2列表中所有的进程
8. 日志操作
# pm2 logs [--raw]   #Display all processes logs in streaming
# pm2 flush              #Empty all log file
# pm2 reloadLogs    #Reload all logs
9. 升级PM2
# npm install pm2@lastest -g   #安装最新的PM2版本
# pm2 updatePM2                    #升级pm2
10. 更多命令参数请查看帮助
# pm2 --help

四、PM2目录结构

默认的目录是:当前用于的家目录下的.pm2目录(此目录可以自定义,请参考:五、自定义启动文件),详细信息如下:
$HOME/.pm2                   #will contain all PM2 related files
$HOME/.pm2/logs           #will contain all applications logs
$HOME/.pm2/pids           #will contain all applications pids
$HOME/.pm2/pm2.log    #PM2 logs
$HOME/.pm2/pm2.pid    #PM2 pid
$HOME/.pm2/rpc.sock    #Socket file for remote commands
$HOME/.pm2/pub.sock   #Socket file for publishable events
$HOME/.pm2/conf.js       #PM2 Configuration

五、自定义启动文件

创建一个test.json的示例文件,格式如下:
{
  "apps":
    {
      "name": "test",
      "cwd": "/data/wwwroot/nodejs",
      "script": "./test.sh",
      "exec_interpreter": "bash",
      "min_uptime": "60s",
      "max_restarts": 30,
      "exec_mode" : "cluster_mode",
      "error_file" : "./test-err.log",
      "out_file": "./test-out.log",
      "pid_file": "./test.pid"
      "watch": false
    }
}

说明:

apps:json结构,apps是一个数组,每一个数组成员就是对应一个pm2中运行的应用
name:应用程序的名称
cwd:应用程序所在的目录
script:应用程序的脚本路径
exec_interpreter:应用程序的脚本类型,这里使用的shell,默认是nodejs
min_uptime:最小运行时间,这里设置的是60s即如果应用程序在60s内退出,pm2会认为程序异常退出,此时触发重启max_restarts设置数量
max_restarts:设置应用程序异常退出重启的次数,默认15次(从0开始计数)
exec_mode:应用程序启动模式,这里设置的是cluster_mode(集群),默认是fork
error_file:自定义应用程序的错误日志文件
out_file:自定义应用程序日志文件
pid_file:自定义应用程序的pid文件
watch:是否启用监控模式,默认是false。如果设置成true,当应用程序变动时,pm2会自动重载。这里也可以设置你要监控的文件。
详细参数列表:见附件八

六、实例

已上面的test.json为例

# cat > /data/wwwroot/nodejs/test.sh << EOF
#!/bin/bash
while :
do
    echo "Test" >> 1.log
    sleep 5
done
EOF
# chmod +x test.sh      #添加执行权限
# pm2 start test.json    #启动,如下图:

# pm2 list    #查看pm2进程,如下图:

七、备注
其他可参数见官网:http://pm2.keymetrics.io
八、附件

Field Type Example Description
name string "myAPI" name your app will have in PM2
script string "bin/app.js" path of your app
args list ["--enable-logs", "-n", "15"] arguments given to your app when it is launched
node_args list ["--harmony", "--max-stack-size=1024"] arguments given to node when it is launched
cwd string "/var/www/app/prod" the directory from which your app will be launched
exec_mode string "cluster" "fork" mode is used by default, "cluster" mode can be configured with instances field
instances number 4 number of instances for your clustered app, 0 means as much instances as you have CPU cores. a negative value means CPU cores - value (e.g -1 on a 4 cores machine will spawn 3 instances)
exec_interpreter string "node" defaults to "node". can be "python", "ruby", "bash" or whatever interpreter you wish to use. "none" will execute your app as a binary executable
log_date_format string "YYYY-MM-DD HH:mm Z" format in which timestamps will be displayed in the logs
error_file string "/var/log/node-app/node-app.stderr.log" path to the specified error log file. PM2 generates one by default if not specified and you can find it by typing pm2 desc <app id>
out_file string "/var/log/node-app/node-app.stdout.log" path to the specified output log file. PM2 generates one by default if not specified and you can find it by typing pm2 desc <app id>
pid_file string "pids/node-geo-api.pid" path to the specified pid file. PM2 generates one by default if not specified and you can find it by typing pm2 desc <app id>
merge_logs boolean false defaults to false. if true, it will merge logs from all instances of the same app into the same file
cron_restart string "1 0 * * *" a cron pattern to restart your app. only works in "cluster" mode for now. soon to be avaible in "fork" mode as well
watch boolean true enables the watch feature, defaults to "false". if true, it will restart your app everytime a file change is detected on the folder or subfolder of your app.
ignore_watch list ["[\/\\]\./", "node_modules"] list of regex to ignore some file or folder names by the watch feature
min_uptime number 1000 min uptime of the app to be considered started (i.e. if the app crashes in this time frame, the app will only be restarted the number set in max_restarts (default 15), after that it's errored)
max_restarts number 10 number of consecutive unstable restarts (less than 1sec interval or custom time via min_uptime) before your app is considered errored and stop being
max_memory_restart string "150M" your app will be restarted by PM2 if it exceeds the amount of memory specified. human-friendly format : it can be "10M", "100K", "2G" and so on...
env object {"NODE_ENV": "production", "ID": "42"} env variables which will appear in your app
autorestart boolean false true by default. if false, PM2 will not restart your app if it crashes or ends peacefully
vizion boolean false true by default. if false, PM2 will start without vizion features (versioning control metadatas)
post_update list ["npm install", "echo launching the app"] a list of commands which will be executed after you perform a Pull/Upgrade operation from Keymetrics dashboard
force boolean true defaults to false. if true, you can start the same script several times which is usually not allowed by PM2
next_gen_js boolean true defaults to false. if true, PM2 will launch your app using embedded BabelJS features which means you can run ES6/ES7 javascript code
restart_delay number 4000 time to wait before restarting a crashed app (in milliseconds). defaults to 0.

  • 还没有评论,沙发等你来抢
  • .

社交帐号登录:

.
.

一聚教程正在使用多说

SSL证书是数字证书的一种,类似于驾驶证、护照和营业执照的电子副本。因为配置在服务器上,也称为SSL服务器证书了,今天我们来看cPanel主机面板安装SSL证书实现HTTPS网址访问例子
SSL证书

SSL证书通过在客户端浏览器和Web服务器之间建立一条SSL安全通道(Secure socket layer(SSL)安全协议是由Netscape Communication公司设计开发。该安全协议主要用来提供对用户和服务器的认证;对传送的数据进行加密和隐藏;确保数据在传送中不被改变,即数据的完整性,现已成为该领域中全球化的标准。由于SSL技术已建立到所有主要的浏览器和WEB服务器程序中,因此,仅需安装服务器证书就可以激活该功能了),即通过它可以激活SSL协议,实现数据信息在客户端和服务器之间的加密传输,可以防止数据信息的泄露。保证了双方传递信息的安全性,而且用户可以通过服务器证书验证他所访问的网站是否是真实可靠。数位签名又名数字标识、签章 (即 Digital Certificate,Digital ID ),提供了一种在网上进行身份验证的方法,是用来标志和证明网路通信双方身份的数字信息文件,概念类似日常生活中的司机驾照或身份证相似。 数字签名主要用于发送安全电子邮件、访问安全站点、网上招标与投标、网上签约、网上订购、安全网上公文传送、网上办公、网上缴费、网上缴税以及网上购物等安全的网上电子交易活动。

最近一段时间老左在玩SSL证书,其中玩过在黑色星期五期间不到1美元一年购买的Namecheap付费SSL证书,也玩过被很多商家和网友推荐的Let's Encrypt免费SSL证书,对于一般的网站用户或者博客用户来说,对于安装何种加密级别的证书其实都没有多大意义,最为主要的是URL头是一个绿色的小锁就感觉高端大气。

鉴于Let's Encrypt第三方支持力度,以及众多网友的热心,老左前天有使用SSL For Free工具可以一键生成证书包,对于安装到VPS服务器中的方法之前也有分享过(在这里),为了体验不同环境的方法,老左还单独在我们很多朋友使用的cPanel面板的虚拟主机环境中架设一个环境且安装前天生成的免费SSL证书到网站中。

第一步、安装SSL证书到cPanel面板准备工作

我们在准备安装网站实现HTTPS网址加密证书访问之前需要将网站添加到cPanel面板中,实现HTTP可以访问,这个就不用在这里教学了,已经很基础的东西。其次,我们需要通过上面SSL For Free方法获取到证书包,且里面有ca_bundle.crt、certificate.crt、private.key三个文件,我们要准备等会需要用到。

这不为了玩转Let's Encrypt免费证书,老左还特意注册到letsencrypt.cc域名,等最后要实现https://www.letsencrypt.cc这样的网址访问形式且需要全部的形式都跳转到HTTPS地址。既然准备工作做好了,那就一起开始吧。

第二步、登录cPanel面板设置添加准备的证书文件

1、登录SSL/TLS 管理器

登录SSL/TLS 管理器

登录CP面板,我们可以看到上图所示,找到SSL/TLS管理器。

管理SSL站点

上面的选项很多,这里直接点击管理SSL站点选项。

2、添加证书文件

选择域名添加证书

这里我们需要选择已经在CP面板中的站点,也就是我们上面准备好的配置和下载到证书的域名,然后在其中的certificate.crt文件的脚本都复制进来,然后会看到对应的域名选项。

添加证书文件

然后将private.key和ca_bundle.crt文件都复制对应的文本框中。点击安装证书,这样可以看到下图。

SSL证书安装完毕

看到这个界面,就表示我们在cpanel面板中部署SSL证书完毕。点击确定之后我们其实就可以用HTTPS地址访问我们的网站。

第三步、强制HTTPS跳转访问站点

一来是为了统一用户访问入口,二来规范化网址,所以必须将当前既可以用HTTP访问,也可以用HTTPS访问网站进行一个统一格式。老左需要将全部用HTTP访问的地址跳转到HTTPS地址来。

强制HTTPS跳转访问站点

因为老左这个站点采用的是ZBLOG PHP程序,所以直接在根目录中的.htaccess文件添加上图所示的4行,无论是HTTP还是不带WWW,都将跳转到HTTPS的WWW形式。
 代码如下 复制代码
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.letsencrypt.cc/$1 [R,L]
RewriteCond %{HTTP_HOST} ^letsencrypt.cc [NC]
RewriteRule ^(.*)$ http://www.letsencrypt.cc/$1 [L,R=301]
我们用浏览器打开网站试试看看是不是有小绿锁。
SSL小绿锁
第四、用SSL工具检测生效及小结
 代码如下 复制代码
在线检测工具:https://www.ssllabs.com/
无论我们用何种证书配置的SSL,都可以用上面的在线工具检测是否成功。
用SSL工具检测生效及小结
检测之后还算不错吧,至此老左利用免费的Let's Encrypt SSL证书生成且安装到站点中,过程还算比较简单,如果我们也是用CP面板虚拟主机建设的站点需要安装SSL证书的,可以参考以上的方法。
本文章来为各位介绍一篇关于Docker之构建Nginx镜像实现迅速搭建Google反代站点的例子,希望文章对大家有帮助.

镜像用法
自备证书用法
docker run -d --name=google \
-p 80:80 -p 443:443 \
-v 系统上存放ssl证书的目录:/usr/local/nginx/conf/ssl \
-e PROXY_GOOGLE=On \
-e PROXY_SSL_CRT_KEY=On \
-e PROXY_CRT=你的crt名称 \
-e PROXY_KEY=你的key名称 \
-e PROXY_DOMAIN=你的域名 \
benyoo/nginx_build:proxy_google

系统自签证书用法
docker run -d --name=google \
-p 80:80 -p 443:443 \
-e PROXY_GOOGLE=On \
-e PROXY_DOMAIN=你的域名 \
benyoo/nginx_build:proxy_google
Docker之构建Nginx镜像实现迅速搭建Google反代站点

FROM centos:6.7

 

Docker之构建Nginx镜像实现迅速搭建Google反代站点


MAINTAINER from www.111cn.net by lookback (mondeolove@gmail.com)

RUN yum clean all && \
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-* && \
yum install -y epel-release && \
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6 && \
yum makecache && \
yum install -y pcre-devel openssl-devel zlib-devel gd-devel tar gcc wget git

RUN groupadd --system www && \
useradd --system --gid www www && \
mkdir -p {/var/log/wwwlogs,/var/run/nginx,/var/lock}

RUN wget -c http://nginx.org/download/nginx-1.9.5.tar.gz && \
git clone https://github.com/cuber/ngx_http_google_filter_module.git && \
git clone https://github.com/yaoweibin/ngx_http_substitutions_filter_module.git && \
git clone https://github.com/aperezdc/ngx-fancyindex.git

RUN tar xf nginx-1.9.5.tar.gz && \
cd nginx-1.9.5 && \
./configure --prefix=/usr/local/nginx \
--user=www --group=www \
--error-log-path=/var/log/wwwlogs/error.log \
--http-log-path=/var/log/wwwlogs/access.log \
--pid-path=/var/run/nginx/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--with-pcre \
--with-ipv6 \
--with-http_ssl_module \
--with-http_flv_module \
--with-http_v2_module \
--with-http_realip_module \
--with-http_gzip_static_module \
--with-http_stub_status_module \
--with-http_mp4_module \
--with-http_image_filter_module \
--with-http_addition_module \
--http-client-body-temp-path=/usr/local/nginx/client/ \
--http-proxy-temp-path=/usr/local/nginx/proxy/ \
--http-fastcgi-temp-path=/usr/local/nginx/fcgi/ \
--http-uwsgi-temp-path=/usr/local/nginx/uwsgi \
--http-scgi-temp-path=/usr/local/nginx/scgi \
--add-module=../ngx_http_google_filter_module \
--add-module=../ngx_http_substitutions_filter_module \
--add-module=../ngx-fancyindex && \
make -j $(awk '/processor/{i++}END{print i}' /proc/cpuinfo) && make install && \
rm -rf ../{ngx_http*,ngx-fancyindex,nginx-1.9.5*}

ADD nginx.conf /usr/local/nginx/conf/nginx.conf

ADD run.sh /run.sh
RUN chmod +x /run.sh

VOLUME ["/home/wwwroot", "/usr/local/nginx/conf/ssl", "/usr/local/nginx/conf/vhost"]

EXPOSE 80 443

ENTRYPOINT ["/run.sh"]

CMD ["nginx"]
#!/bin/sh
#########################################################################
# File Name: run.sh
# Author: LookBack
# Email: admin#111cn.net
# Version:
# Created Time: 2015年11月17日 星期二 10时29分55秒
#########################################################################
PATH=/bin:/usr/local/nginx/sbin:$PATH
Nginx_Install_Dir=/usr/local/nginx

set -e

if [ -n "$TIMEZONE" ]; then
        rm -rf /etc/localtime && \
        ln -s /usr/share/zoneinfo/$TIMEZONE /etc/localtime
fi

if [ "${1:0:1}" = '-' ]; then
        set -- nginx "$@"
fi

if [ -z "$DATA_DIR" ]; then
        DATA_DIR=/home/wwwroot
fi

sed -i "s@/home/wwwroot@$DATA_DIR@" $Nginx_Install_Dir/conf/nginx.conf
mkdir -p ${DATA_DIR}
[ ! -f "$DATA_DIR/index.html" ] && echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

 

<h1 style="text-align:center;">
                <span style="line-height:1.5;"><span style="color:#337FE5;">Hello world! This Nginx!</span>
</span><span style="line-height:1.5;color:#E53333;">Welcome to use Docker!</span>
        </h1>


<h1 style="text-align:center;">
                <span style="line-height:1.5;color:#E53333;">^_^┢┦aΡpy&nbsp;</span>
        </h1>

 

 

       


' > $DATA_DIR/index.html
chown -R www.www $DATA_DIR

CPU_num=$(awk '/processor/{i++}END{print i}' /proc/cpuinfo)
if [ "$CPU_num" == '2' ];then
    sed -i 's@^worker_processes.*@worker_processes 2;\nworker_cpu_affinity 10 01;@' $Nginx_Install_Dir/conf/nginx.conf
elif [ "$CPU_num" == '3' ];then
    sed -i 's@^worker_processes.*@worker_processes 3;\nworker_cpu_affinity 100 010 001;@' $Nginx_Install_Dir/conf/nginx.conf
elif [ "$CPU_num" == '4' ];then
    sed -i 's@^worker_processes.*@worker_processes 4;\nworker_cpu_affinity 1000 0100 0010 0001;@' $Nginx_Install_Dir/conf/nginx.conf
elif [ "$CPU_num" == '6' ];then
    sed -i 's@^worker_processes.*@worker_processes 6;\nworker_cpu_affinity 100000 010000 001000 000100 000010 000001;@' $Nginx_Install_Dir/conf/nginx.conf
elif [ "$CPU_num" == '8' ];then
    sed -i 's@^worker_processes.*@worker_processes 8;\nworker_cpu_affinity 10000000 01000000 00100000 00010000 00001000 00000100 00000010 00000001;@' $Nginx_Install_Dir/conf/nginx.conf
else
    echo Google worker_cpu_affinity
fi

if [[ -n "$PROXY_GOOGLE" ]]; then
        [ -f "${Nginx_Install_Dir}/conf/ssl" ] || mkdir -p $Nginx_Install_Dir/conf/ssl
        [ -f "${Nginx_Install_Dir}/conf/vhost" ] || mkdir -p $Nginx_Install_Dir/conf/vhost

        if [ -z "$PROXY_DOMAIN" ]; then
                echo >&2 'error:  missing PROXY_DOMAIN'
                echo >&2 '  Did you forget to add -e PROXY_DOMAIN=... ?'
                exit 1
        fi

        if [ -n "$PROXY_SSL_CRT_KEY" ]; then
                if [ -z "$PROXY_CRT" ]; then
                        echo >&2 'error:  missing PROXY_CRT'
                        echo >&2 '  Did you forget to add -e PROXY_CRT=... ?'
                        exit 1
                fi

                if [ -z "$PROXY_KEY" ]; then
                        echo >&2 'error:  missing PROXY_KEY'
                        echo >&2 '  Did you forget to add -e PROXY_KEY=... ?'
                        exit 1
                fi

                if [ -f "${Nginx_Install_Dir}/conf/ssl/${PROXY_CRT}" ]; then
                        echo >&2 'error:  missing PROXY_CRT'
                        echo >&2 "  You need to put ${PROXY_CRT} in ssl directory"
                        exit 1
                fi

                if [ -f "${Nginx_Install_Dir}/conf/ssl/${PROXY_KEY}" ]; then
                        echo >&2 'error:  missing PROXY_CSR'
                        echo >&2 "  You need to put ${PROXY_KEY} in ssl directory"
                        exit 1
                fi
        else
                openssl req -new -newkey rsa:2048 -nodes \
                        -out $Nginx_Install_Dir/conf/ssl/$PROXY_DOMAIN.csr \
                        -keyout $Nginx_Install_Dir/conf/ssl/$PROXY_DOMAIN.key \
                        -subj "/C=CN/ST=Shanghai/L=Pudong/O=Legion/OU=DevOps/CN=$PROXY_DOMAIN/emailAddress=admin@111cn.net"
                openssl x509 -req -days 365 -in $Nginx_Install_Dir/conf/ssl/$PROXY_DOMAIN.csr \
                        -signkey $Nginx_Install_Dir/conf/ssl/$PROXY_DOMAIN.key \
                        -out $Nginx_Install_Dir/conf/ssl/$PROXY_DOMAIN.crt

                rm -rf $Nginx_Install_Dir/conf/ssl/$PROXY_DOMAIN.csr

                PROXY_KEY=${PROXY_DOMAIN}.key
                PROXY_CRT=${PROXY_DOMAIN}.crt
        fi

        #sed -i '57,87d' $Nginx_Install_Dir/conf/nginx.conf
        cat > ${Nginx_Install_Dir}/conf/vhost/google.conf << EOF
server {
        listen 80;
        server_name $PROXY_DOMAIN;
        return 301 https://$PROXY_DOMAIN\$request_uri;
}

server {
        listen 443 ssl;
        server_name $PROXY_DOMAIN;

        ssl on;
        ssl_certificate ssl/${PROXY_CRT};
        ssl_certificate_key ssl/${PROXY_KEY};
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_prefer_server_ciphers on;
        ssl_ciphers ALL:!aNULL:!ADH:!eNULL:!LOW:!EXP:RC4+RSA:+HIGH:+MEDIUM;
        keepalive_timeout 70;
        ssl_session_cache shared:SSL:10m;
        ssl_session_timeout 10m;

        resolver 8.8.8.8;
        location / {
                google on;
                google_scholar on;
                google_language zh-CN;
                google_robots_allow on;
        }
}
EOF
        #mv ${Nginx_Install_Dir}/vhost/{google.conf.stop,google.conf}
fi

exec "$@" -g "daemon off;"
user www www;
worker_processes auto;

error_log /var/log/wwwlogs/error_nginx.log crit;
pid /var/run/nginx.pid;
worker_rlimit_nofile 51200;

events {
    use epoll;
    worker_connections 51200;
}

http {
    include mime.types;
    default_type application/octet-stream;
    server_names_hash_bucket_size 128;
    client_header_buffer_size 32k;
    large_client_header_buffers 4 32k;
    client_max_body_size 50m;
    sendfile on;
    tcp_nopush on;
    keepalive_timeout 120;
    server_tokens off;
    tcp_nodelay on;

    fastcgi_connect_timeout 300;
    fastcgi_send_timeout 300;
    fastcgi_read_timeout 300;
    fastcgi_buffer_size 64k;
    fastcgi_buffers 4 64k;
    fastcgi_busy_buffers_size 128k;
    fastcgi_temp_file_write_size 128k;

    #Gzip Compression
    gzip on;
    gzip_buffers 16 8k;
    gzip_comp_level 6;
    gzip_http_version 1.1;
    gzip_min_length 256;
    gzip_proxied any;
    gzip_vary on;
    gzip_types
    text/xml application/xml application/atom+xml application/rss+xml application/xhtml+xml image/svg+xml
    text/javascript application/javascript application/x-javascript
    text/x-json application/json application/x-web-app-manifest+json
    text/css text/plain text/x-component
    font/opentype application/x-font-ttf application/vnd.ms-fontobject
    image/x-icon;
    gzip_disable  "msie6";

    #If you have a lot of static files to serve through Nginx then caching of the files' metadata (not the actual files' contents) can save some latency.
    open_file_cache max=1000 inactive=20s;
    open_file_cache_valid 30s;
    open_file_cache_min_uses 2;
    open_file_cache_errors on;

    server {
        listen 80;
        server_name -;
        root /home/wwwroot;
        index index.html index.php index.jsp;
        access_log /var/log/wwwlogs/access_nginx.log combined;

        location /status {
            stub_status on;
            auth_basic "WebServer Status";
        }

#        location ~ .*\.(php|php5)?$ {
#            #fastcgi_pass remote_php_ip:9000;
#            fastcgi_pass unix:/dev/shm/php-cgi.sock;
#            fastcgi_index index.php;
#            include fastcgi.conf;
#        }

        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|ico)$ {
            expires 30d;
        }

        location ~ .*\.(js|css)?$ {
            expires 7d;
        }
    }

##########################vhost#####################################
    include vhost/*.conf;
}